From a463dccd81a0f542afd120e7feb48457663ae507 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 18 Jan 2020 14:18:47 -0500 Subject: [PATCH] Refine the selector tree printing Also show which tree nodes have exact matches. --- gtk/gtkcssselector.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gtk/gtkcssselector.c b/gtk/gtkcssselector.c index c83f42f419..dc35d839db 100644 --- a/gtk/gtkcssselector.c +++ b/gtk/gtkcssselector.c @@ -1970,6 +1970,7 @@ _gtk_css_selector_tree_print (const GtkCssSelectorTree *tree, GString *str, char { gboolean first = TRUE; int len, i; + gpointer *matches; for (; tree != NULL; tree = gtk_css_selector_tree_get_sibling (tree), first = FALSE) { @@ -1993,6 +1994,16 @@ _gtk_css_selector_tree_print (const GtkCssSelectorTree *tree, GString *str, char len = str->len; tree->selector.class->print (&tree->selector, str); + matches = gtk_css_selector_tree_get_matches (tree); + if (matches) + { + int n; + for (n = 0; matches[n] != NULL; n++) ; + if (n == 1) + g_string_append (str, " (1 match)"); + else + g_string_append_printf (str, " (%d matches)", n); + } len = str->len - len; if (gtk_css_selector_tree_get_previous (tree)) -- 2.30.2